# -*- coding: utf-8 -*-
from pymongo import MongoClient


client = MongoClient()
c = client['java']['java']

class Scrapy3Pipeline(object):
    def process_item(self, item, spider):
        # if spider.name == 'dy':
        #     with open('/home/python/Desktop/斗鱼img/' + str(random.randrange(1, 1000, 4)) + item['img_name'], 'wb' ) as f:
        #         f.write(item['img_b'])
        #     print(item['img_name'], '保存成功')
        # if spider.name == 'lagou':
        #     c.insert_one(item)
        #     print('lagou_spider')

        return item

    def open_spider(self, spider):
        print('爬虫启动---------------------')
        print()
        print()

    def close_spider(self, spider):
        print()
        print()
        print('---------------------爬虫结束')
